<template>
  <div class="app-container statistics-layout">
    <!-- 顶部视角切换 -->
    <el-card class="view-selector-card">
      <div class="view-selector">
        <span class="selector-title">统计视角：</span>
        <el-radio-group v-model="currentView" @change="handleViewChange" class="view-radio-group">
          <el-radio-button label="engineer">个人工时</el-radio-button>
          <el-radio-button label="pm">项目工时统计</el-radio-button>
          <el-radio-button label="sales">销售业绩</el-radio-button>
        </el-radio-group>
      </div>
    </el-card>

    <!-- 工程师视角：我的工时 -->
    <div v-if="currentView === 'engineer'" class="engineer-view">
      <EngineerWorklogView />
    </div>

    <!-- 项目经理视角：项目工时统计 -->
    <div v-if="currentView === 'pm'" class="pm-view">
      <PMWorklogView />
    </div>

    <!-- 销售视角：销售业绩 -->
    <div v-if="currentView === 'sales'" class="sales-view">
      <SalesStatsView />
      </div>
  </div>
</template>

<script>
// 导入子组件
import EngineerWorklogView from './components/EngineerWorklogView.vue'
import PMWorklogView from './components/PMWorklogView.vue'
import SalesStatsView from './components/SalesStatsView.vue'

export default {
  name: 'Statistics',
  components: {
    EngineerWorklogView,
    PMWorklogView,
    SalesStatsView
  },
  data() {
    return {
      currentView: 'engineer' // 默认显示工程师视角
    }
  },
  methods: {
    handleViewChange(value) {
      this.currentView = value
    }
  }
}
</script>

<style scoped>
.statistics-layout {
  min-height: 80vh;
  background: linear-gradient(135deg, #f0f4ff 0%, #f8fafc 100%);
  padding: 20px;
}

.view-selector-card {
  margin-bottom: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 12px 0 rgba(80,120,255,0.06);
}

.view-selector {
  display: flex;
  align-items: center;
  padding: 10px 0;
}

.selector-title {
  font-size: 16px;
  font-weight: 600;
  color: #2d3a4b;
  margin-right: 20px;
}

.view-radio-group {
  display: flex;
}

.view-radio-group .el-radio-button__inner {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  margin-right: 8px;
  border: 1px solid #dcdfe6;
  transition: all 0.3s;
}

.view-radio-group .el-radio-button__inner:hover {
  color: #409eff;
  border-color: #409eff;
}

.view-radio-group .el-radio-button.is-active .el-radio-button__inner {
  background: #409eff;
  border-color: #409eff;
  color: #fff;
  box-shadow: 0 2px 8px rgba(64, 158, 255, 0.3);
}

.engineer-view,
.pm-view,
.sales-view {
  min-height: 60vh;
}

/* 通用样式 */
.el-card {
  border-radius: 12px !important;
  box-shadow: 0 2px 12px 0 rgba(80,120,255,0.06);
}

.el-card__header {
  font-size: 16px;
  font-weight: 700;
  color: #2d3a4b;
  background: #f5f7fa;
  border-radius: 12px 12px 0 0;
}

.el-table {
  border-radius: 8px;
  overflow: hidden;
    font-size: 14px;
}

.el-table th {
  background: #f5f7fa !important;
  font-weight: bold;
  color: #333;
}

.el-table tr:hover > td {
  background: #e8f0fe !important;
}

/* 状态标签样式 */
.status-tag {
  display: inline-block;
  min-width: 32px;
  max-width: 80px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  background: rgba(120,120,120,0.08);
  color: #333;
  margin: 0 1px;
  line-height: 1.5;
  white-space: nowrap;
}

.status-green { background: rgba(34,197,94,0.18); color: #219150; }
.status-orange { background: rgba(251,191,36,0.18); color: #b97a0a; }
.status-red { background: rgba(239,68,68,0.18); color: #c81d1d; }
.status-blue { background: rgba(59,130,246,0.15); color: #2563eb; }
.status-gray { background: rgba(120,130,150,0.15); color: #5a6a7a; }
.status-default { background: rgba(120,120,120,0.08); color: #666; }

@media (max-width: 768px) {
  .statistics-layout {
    padding: 10px;
  }
  
  .view-selector {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .selector-title {
    margin-bottom: 10px;
    margin-right: 0;
  }
  
  .view-radio-group {
    width: 100%;
  }
  
  .view-radio-group .el-radio-button {
    flex: 1;
  }
  
  .view-radio-group .el-radio-button__inner {
    width: 100%;
    text-align: center;
    margin-right: 4px;
    padding: 8px 12px;
  }
}
</style> 